package com.jy.rhin.infra.cda.feign;

import com.jy.api.hospital.HospitalAPI;
import com.jy.api.hospital.dto.HospitalDTO;
import com.jy.framework.base.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author dhl
 * @date 2023/2/22
 * @Description
 */
@Component
@Slf4j
public class HospitalService {

    @Resource
    private HospitalAPI hospitalAPI;

    public HospitalDTO queryHospital(String hospitalId){
        Result<HospitalDTO> api = hospitalAPI.info(hospitalId);
        if (!Objects.isNull(api) && api.isSuccess() && !Objects.isNull(api.getData())) {
            return api.getData();
        }
        log.error("医疗机构获取失败");
        return null;
    }
}
